home *** CD-ROM | disk | FTP | other *** search
- Path: news1.h1.usa.pipeline.com!usenet
- From: grantp@usa.pipeline.com
- Newsgroups: comp.lang.c++
- Subject: Cost of virtual dispatch - was Re: Faster FILE subroutines in standard C?
- Date: 8 Jan 1996 18:51:50 GMT
- Organization: Kalevi, Inc
- Message-ID: <4crp46$n5s@news1.usa.pipeline.com>
- References: <4crl7s$h4r@gold.datalytics.com>
- NNTP-Posting-Host: pipe4.h1.usa.pipeline.com
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete)
- X-Newsreader: Pipeline USA v3.3.0
-
- On Jan 08, 1996 17:45:32 in article <Re: Faster FILE subroutines in
- standard C?>, 'Rob Stewart <stew@datalytics.com>' wrote:
-
- >
- >As soon as you make use of virtual base classes, polymorphism,
- >etc., your code runs slower.
-
- This has been discussed previously more than once in this
- newsgroup and it has been shown that EQUIVALENT C++
- code is not slower. If you compare with a static function
- call to a virtual one, there's a price to pay -- albeit a very
- small one. But equivalent C code must select the appropriate
- function to call, typically using a switch statement. The
- combination of selection by switch and calling a static
- function is not slower than a call to a virtual function.
-
- > The advantage is type safety,
- >flexibility, and ease of expression. There are always
- >tradeoffs to be made.
-
- Previous discussion also pointed out that even if considering
- only the function calls themselves, this 'tradeoff' is negligible
- in comparison with the overall program execution.
- A programmer would be wise to direct his/her efforts towards
- improving algorithms rather than the cost of late binding.
-
- --
-
- Pete
-
-
-
-
-
-